package benchmarks.tpch;

import api.BenchmarkModule;
import api.Configuration;
import api.Terminal;
import benchmarks.tpch.mongo.TPCHWorkerMongo;
import benchmarks.tpch.mysql.TPCHWorkerMySQL;
import benchmarks.tpch.redis.TPCHWorkerRedis;

import java.util.Random;

public class TPCHTerminal extends Terminal {
    public TPCHTerminal(BenchmarkModule benchmarkModule, Configuration config, int id) {
        super(benchmarkModule, config, id);
        if (benchmarkModule.getDatabaseName().equals(BenchmarkModule.MongoName)) {
            worker = new TPCHWorkerMongo(config);
        } else if (benchmarkModule.getDatabaseName().equals(BenchmarkModule.MySqlName)) {
            worker = new TPCHWorkerMySQL(config);
        } else if (benchmarkModule.getDatabaseName().equals(BenchmarkModule.RedisName)) {
            worker = new TPCHWorkerRedis(config);
        }
    }

    protected final int pickNextProcedure(int current, Random random) {
        current = current + 1;
        if (current >= procedures.size()) {
            current = 0;
        }
        return current;
    }
}
